#ifndef _CHECK_H_
#define _CHECK_H_

#define SOFT_VER_1 1
#define SOFT_VER_2 1

#define Break_In_GPIO    GPIOC
#define Water_Press_GPIO GPIOC
#define QBH_GPIO         GPIOC
#define C_Fault_GPIO     GPIOB
#define HG_GPIO          GPIOC
#define RE_GPIO          GPIOC
#define RTS_GPIO         GPIOC
#define CAN_GPIO         GPIOA

#define Break_In_Pin    GPIO_PIN_2
#define Water_Press_Pin GPIO_PIN_12
#define QBH_Pin         GPIO_PIN_11
#define C_Fault_Pin     GPIO_PIN_8
#define HG_Pin          GPIO_PIN_15
#define RE_Pin          GPIO_PIN_8
#define RTS_Pin         GPIO_PIN_9
#define CAN_RX_Pin      GPIO_PIN_11
#define CAN_TX_Pin      GPIO_PIN_12

#define C_FAULT(a)  HAL_GPIO_WritePin(C_Fault_GPIO, C_Fault_Pin, a)
#define HG_CTRL(a)  HAL_GPIO_WritePin(HG_GPIO, HG_Pin, a)
#define RE_CTRL(a)  HAL_GPIO_WritePin(RE_GPIO, RE_Pin, a)
#define RTS_CTRL(a) HAL_GPIO_WritePin(RTS_GPIO, RTS_Pin, a)

#define GPIO_PortSource_Brake GPIO_PortSourceGPIOC
#define GPIO_PinSource_Brake  GPIO_PinSource2
#define EXTI_Line_Brake       EXTI_Line2
#define Brake_Trigger         EXTI_Trigger_Rising

#define Backups_Data 0xA5

extern unsigned char brake_state;
extern unsigned char uperMonitor;
extern unsigned char pd1_check_start;
extern unsigned char master_comm_err;

extern ULONG power_comm_timestamp;

extern TX_SEMAPHORE binary_pd_success_check;

extern TX_THREAD     pd_success_check_thread_handle;
extern unsigned char pd_success_check_thread_stack[1024];

extern TX_THREAD     pd1_check_thread_handle;
extern unsigned char pd1_check_thread_stack[1024];

extern TX_THREAD     pd2_check_thread_handle;
extern unsigned char pd2_check_thread_stack[1024];

extern TX_THREAD     pump_pd_check_thread_handle;
extern unsigned char pump_pd_check_thread_stack[1024];

extern TX_TIMER     cycle_check_timer;
extern unsigned int master_comm_err_cnt;

extern TX_QUEUE queue_emit_success;

extern ULONG pump_comm_timestamp[4];

extern unsigned char modul1_State_Mask;
extern unsigned char modul2_State_Mask;
extern unsigned char modul3_State_Mask;
extern unsigned char modul4_State_Mask;

extern unsigned char err_dispose_finish;

void cycle_check_timer_callback(ULONG arg);
void pd1_check_thread(ULONG arg);
void pd_success_check_thread(ULONG arg);
void pd2_check_thread(ULONG arg);
void pump_pd_check_thread(ULONG arg);

void Laser_Health_Refresh(void);
void clear_pd_check_var(void);
void GPIO_Check(void);
void environment_check(void);
void clear_check_cnt(void);
void ntc_check(void);
void init_check_var(void);

#endif
